import { Module } from "@nestjs/common";
import { JwtModule } from "@nestjs/jwt";
import { ConfigService } from "@nestjs/config";
import { PassportModule } from "@nestjs/passport";


@Module({
  imports: [
    /* jwt模块 */
    JwtModule.registerAsync({
      global: true,
      useFactory: async (configService: ConfigService) => ({
        secret: configService.get("jwt.secret"),
        signOptions: {
          expiresIn: configService.get("jwt.expiresIn")
        }
      }),
      inject: [ConfigService]
    }),
    /* 注册默认策略 */
    PassportModule.register({ defaultStrategy: "jwt" })
  ]
})
export class AuthModule {
}
